﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.constant;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;
using System.Text;

namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("OutVarName")]
    public class ReadFileNParam:BaseParam {
        //保存方式0文本，1列表，2二进制
        private int saveType = 0;
        private string outVarName = "fileContent";
        //0UTF-8,1UTF-32,2ANSI
        private int encodeType = 0;
        private string filePath = "";

        public int SaveType {
            get => saveType; 
            set { 
                saveType = value;
                NotifyPropertyChanged("SaveType");
            }  
        }
        public string OutVarName {
            get => outVarName; 
            set { 
                outVarName = value;
                NotifyPropertyChanged("OutVarName");
            }  
        }
        public int EncodeType {
            get => encodeType; 
            set { 
                encodeType = value;
                NotifyPropertyChanged("EncodeType");
            }
        }

        public Encoding EncodingType {
            get { 
                switch (encodeType) { 
                    case 0:
                        return Encoding.UTF8;
                    case 1:
                        return Encoding.UTF32;
                    case 2:
                        return Encoding.ASCII;
                    default:
                        return Encoding.UTF8;
                }
            } 
        }
        public string FilePath {
            get => filePath; 
            set { 
                filePath = value;
                NotifyPropertyChanged("FilePath");
            }  
        }
        public string GetTranslateSaveType() {
            switch(this.saveType) {
                case 0:
                    return "文本";
                case 1:
                    return "列表(每行一个列表项)";
                case 2:
                    return "二进制";
                default : return "文本";
            }
        }
        public string GetTranslateEncodeType() {
            switch(this.saveType) {
                case 0:
                    return "UTF-8";
                case 1:
                    return "UTF-32";
                case 2:
                    return "ANSI";
                default : return "UTF-8";
            }
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.outVarName = this.GetLatestName(this.outVarName, globleData);
        }
    }
}
